﻿using System.Collections.Generic;
using UnityEngine;

public class LockUIMgr
{
    private Transform trans;
    private FullMask mask;

    private bool isLock = false;
    private List<int> lockList;

    public LockUIMgr()
    {
        trans = AllUpdate.GetChildByName("LockUI");
        mask = trans.GetComponentInChildren<FullMask>();

        Utility.SetActive(trans, false);
        lockList = new List<int>();
    }

    public GameObject MaskGo
    {
        get { return mask.gameObject; }
    }

    public GameObject AddLock(int key)
    {
        if (!lockList.Contains(key))
        {
            lockList.Add(key);
        }
        if (!isLock)
        {
            Utility.SetActive(trans, true);
            isLock = true;
        }
        mask.Start();
        return MaskGo;
    }

    public void DelLock(int key)
    {
        lockList.Remove(key);
        if (lockList.Count == 0)
        {
            if (isLock)
            {
                Utility.SetActive(trans, false);
                isLock = false;
            }
        }
    }
}